package com.celeste.mcpserverfeishu.config;

import com.celeste.mcpserverfeishu.api.FeishuApi;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;

/**
 * Retrofit配置类
 */
@Configuration
@RequiredArgsConstructor
public class RetrofitConfig {

    private final FeishuConfig feishuConfig;
    private final ObjectMapper objectMapper;

    /**
     * 创建飞书API客户端
     *
     * @return 飞书API客户端
     */
    @Bean
    public FeishuApi feishuApi() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(feishuConfig.getBaseUrl())
                .addConverterFactory(JacksonConverterFactory.create(objectMapper))
                .build();
        
        return retrofit.create(FeishuApi.class);
    }
} 